package com.juyu.miliao.authentication.security;

import com.juyu.miliao.common.domain.CommonHead;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.GrantedAuthority;

import java.util.Collection;

public class PhoneNumberRegisterToken extends UsernamePasswordAuthenticationToken {
    private static final long serialVersionUID = 2179298295179351758L;
    private String nickName;
    private int sex;
    private String icon;
    private String ip;

    /**
     * 通用请求头
     */
    private CommonHead commonHead;

    public PhoneNumberRegisterToken(Object principal, Object credentials, Collection<? extends GrantedAuthority> authorities) {
        super(principal, credentials, authorities);
    }


    public PhoneNumberRegisterToken(Object principal, Object credentials, String nickName, int sex, String icon,
                                    String ip, CommonHead commonHead) {
        super(principal, credentials);
        if (commonHead == null) {
            throw new RuntimeException("commonHead can not be null");
        }
        this.nickName = nickName;
        this.sex = sex;
        this.icon = icon;
        this.ip = ip;
        this.commonHead = commonHead;
    }

    public String getNickName() {
        return nickName;
    }

    public int getSex() {
        return sex;
    }

    public String getIcon() {
        return icon;
    }

    public String getIp() {
        return ip;
    }

    public CommonHead getCommonHead() {
        return commonHead;
    }
}
